layui.use(['layer','util','form'],function (){
    let layer = layui.layer,util = layui.util,form = layui.form;
    form.render();
})

/**
* @author: ChengJW
* @params:
* @return:
* @date: 2021/9/21
* @description: 查询企业信息
*/
function selectCompanyBaseInfo() {
    //商事主体类型
    let cyBussType = $("input[name='cyBussType']:checked").val();
    //受理号
    let cyAcptId = $("input[name='cyAcptId']").val().trim();
    //统一社会信用代码
    let cyCreditCode = $("input[name='cyCreditCode']").val().trim();

    if (valueIsEmpty(cyAcptId)){
        layer.msg("对不起！请您输入受理号",{icon:2,time:1000});
        return;
    }
    let jsonData = {
        "cyBussType" : cyBussType,
        "cyAcptId" : cyAcptId,
        "cyCreditCode" : cyCreditCode
    }
    sendAjax("/business/archivesAccept/selectCompanyBaseInfo",jsonData,function (result) {
        cleanTableData();
        if (valueIsEqual("00",result.code)){
            let vo = result.data;
            $(".cyAcptId").html(vo.cyAcptId);
            $(".cyAcpterNm").html(vo.cyAcpterNm);
            $(".cyAcptDt").html(layui.util.toDateString(vo.cyAcptDt,"yyyy-MM-dd"));
            $(".cyApvlDt").html(layui.util.toDateString(vo.cyApvlDt,"yyyy-MM-dd"));
            $(".cyRegistId").html(vo.cyRegistId);
            $(".cyNm").html(vo.cyNm);
            $(".cyCreditCode").html(vo.cyCreditCode);
            $(".cyPripalNm").html(vo.cyPripalNm);
            $(".cyRegistDeptNm").html(vo.cyRegistDeptNm);
            $(".cyMgeNm").html(vo.cyMgeNm);
            $(".cyRegistDt").html(layui.util.toDateString(vo.cyRegistDt,"yyyy-MM-dd"));
            $(".cyBuessAds").html(vo.cyBuessAds);
            $(".cyBuessScope").html(vo.cyBuessScope);
            $(".cyOwner").html(vo.cyOwner);
            $(".cyType").html(vo.cyType);
            $(".cyBussType").html(vo.cyBussType);
            $(".cyTradeTpye").html(vo.cyTradeTpye);
            $(".cyRegistAmt").html(vo.cyRegistAmt+vo.cyCurrency);
            $(".cyArchTpye").html(vo.cyArchTpye);
            $(".cyOpenLimitDt").html(layui.util.toDateString(vo.cyOpenLimitDt,"yyyy-MM-dd"));
            $(".cyPhone").html(vo.cyPhone);
            $(".cyAresTolNum").html(vo.cyAresTolNum+'页');
        }else if (valueIsEqual("01",result.code)){
            top.layer.alert("对不起，没有查询到您要的企业信息");
        }else {
            top.layer.alert(result.msg);
        }
    })

}

/**
* @author: ChengJW
* @params:
* @return:
* @date: 2021/9/21
* @description: 登记查询到的企业
*/
function insertAcceptBaseInfo() {
    //受理号
    let cyAcptId = $(".cyAcptId").html();
    if(valueIsEmpty(cyAcptId)){
        top.layer.alert("请您先查询想要登记的企业！");
        return;
    }
    let jsonData = {
        "atAcptId" : cyAcptId
    }
    sendAjax("/business/archivesAccept/insetCompanyInfoIntoTable",jsonData,function (result) {
        if (valueIsEqual("00",result.code)){
            let index = top.layer.alert("企业登记已完成",{icon:1},function (index) {
                cleanTableData();
                top.layer.close(index);
            });
        }else if (valueIsEqual("01",result.code)){
            top.layer.alert("对不起，该企业登记失败，请稍后再试");
        }else {
             top.layer.alert(result.msg,{icon:2,title:'提示！！！'},function (index) {
                 cleanTableData();
                 top.layer.close(index);
            });
        }
        
    })
}
/**
* @author: ChengJW
* @params:
* @return:
* @date: 2021/9/21
* @description: 清除表格中的数据
*/
function cleanTableData(){
    $(".cyAcptId").html("");
    $(".cyAcpterNm").html("");
    $(".cyAcptDt").html("");
    $(".cyApvlDt").html("");
    $(".cyRegistId").html("");
    $(".cyNm").html("");
    $(".cyCreditCode").html("");
    $(".cyPripalNm").html("");
    $(".cyRegistDeptNm").html("");
    $(".cyMgeNm").html("");
    $(".cyRegistDt").html("");
    $(".cyBuessAds").html("");
    $(".cyBuessScope").html("");
    $(".cyOwner").html("");
    $(".cyType").html("");
    $(".cyBussType").html("");
    $(".cyTradeTpye").html("");
    $(".cyRegistAmt").html("");
    $(".cyArchTpye").html("");
    $(".cyOpenLimitDt").html("");
    $(".cyPhone").html("");
    $(".cyAresTolNum").html("");
}